package com.pan.test.entity.vo;

public class ResponseVO<T> {
    private String status;
    private Integer code;
    private String info;
    private T data;

    public ResponseVO() {
    }

    public ResponseVO(Integer code, String info, T data) {
        this.code = code;
        this.info = info;
        this.data = data;
    }

    public static <T> ResponseVO<T> success(T data) {
        return new ResponseVO<>(200, "操作成功", data);
    }

    public static <T> ResponseVO<T> success() {
        return success(null);
    }

    public static <T> ResponseVO<T> error(String message) {
        ResponseVO<T> response = new ResponseVO<>(500, message, null);
        response.setStatus("error");
        return response;
    }

    public static <T> ResponseVO<T> error(Integer code, String message) {
        ResponseVO<T> response = new ResponseVO<>(code, message, null);
        response.setStatus("error");
        return response;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }
}
